package com.chisheng.caa.handler;

import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;

import java.net.URL;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * URL 类型处理器
 * <p>
 * bug: 读取数据时不能转换
 */
@Deprecated
public class URLTypeHandler extends BaseTypeHandler<URL> {

    @Override
    public void setNonNullParameter(PreparedStatement ps, int i, URL parameter, JdbcType jdbcType) throws SQLException {
        ps.setURL(i, parameter);
    }

    @Override
    public URL getNullableResult(ResultSet rs, String columnName) throws SQLException {
        return rs.getURL(columnName);
    }

    @Override
    public URL getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
        return rs.getURL(columnIndex);
    }

    @Override
    public URL getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
        return cs.getURL(columnIndex);
    }

}
